﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RooHui.Infrastructure.Configuration;
using RooHui.Tool;

namespace RooHui.Portal.Biz.Content
{

    public class EmailBuilder
    {
        /// <summary>
        /// 注册，发送邮箱验证邮件
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static string BuildRegisterActivtionEmail(string userName, string token)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
            sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
            sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
            sb.AppendLine(".content-line-right{float: right;}");
            sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
            sb.AppendLine(".content-logo{}");
            sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
            sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
            sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
            sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
            sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
            sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
            sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
            sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
            sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
            sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
            sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
            sb.AppendLine(".content-footer-left{float: left;}");
            sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
            sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
            sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
            sb.AppendLine("</style>");
            sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
            sb.AppendLine("<img src=\"http://" + SiteSettings.Domain + SiteSettings.Logo + "\" /></div>");
            sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
            sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
            sb.AppendLine("<p>尊敬的用户：" + userName + "，<br/>您好！</p>");
            sb.AppendLine("<p>欢迎您注册" + SiteSettings.SiteName + "，请点击以下链接激活您的账号</p>");
            sb.AppendLine("<p><a href=\"http://" + SiteSettings.Domain + "/account/activation?token=" + token + "\">http://" +
                SiteSettings.Domain + "/account/activation?token=" + token + "</a></p>");
            sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
            sb.AppendLine("<a href=\"http://" + SiteSettings.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteSettings.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
            sb.AppendLine("<a href=\"http://" + SiteSettings.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
            sb.AppendLine("地址：" + SiteSettings.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteSettings.CompanyPhone);
            sb.AppendLine("</div></div></div></div>");
            return sb.ToString();
        }

        public static string BuildResetPasswordEmail(string userName, string token)
        {
            string url = "http://" + SiteSettings.Domain + "/account/checkresetpassword?token=" + token + "&u=" + EncodeByBase64.Encode(userName);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine(".content{margin-left: auto;margin-right: auto;width: 700px;margin-top: 20px;line-height:160%;}");
            sb.AppendLine(".content-line{overflow: hidden;width: 100%;}");
            sb.AppendLine(".content-line-left{float: left;overflow: hidden;}");
            sb.AppendLine(".content-line-right{float: right;}");
            sb.AppendLine(".content-line-vspace{float: left;width: 15px;overflow: hidden;height: 1px;}");
            sb.AppendLine(".content-logo{}");
            sb.AppendLine(".content-topright{margin-top: 35px;margin-right: 5px;}");
            sb.AppendLine(".content-topright a{color: #333;text-decoration: none;}");
            sb.AppendLine(".content-topright span{color: #E1E1E1;padding: 0 5px;}");
            sb.AppendLine(".hline{overflow: hidden;height: 15px;width: 100%;margin-top: 4px;border-top: 1px solid #fafafa;}");
            sb.AppendLine(".content-toprighttext{padding-top: 15px;}");
            sb.AppendLine(".box{overflow: hidden;margin-left: auto;margin-right: auto;border-right: 1px solid #F0F6FA;border-bottom: 1px solid #F0F6FA;padding: 0 1px 1px 0;background-color: #E0ECF5;color: #4f4e4e;	padding-bottom: 1px;padding-right:1px;}");
            sb.AppendLine(".boxbg{background-color: #F9FCFD;border: 1px solid #BDC8D9;padding-left:20px;padding-right:20px;padding-top:10px;padding-bottom:20px;}");
            sb.AppendLine(".box-title{padding: 15px 10px 5px 10px;border-bottom: 1px solid #F3F3F3;margin-bottom: 5px;}");
            sb.AppendLine(".box-line{overflow: hidden;padding: 5px 10px 5px 10px;}");
            sb.AppendLine(".box-dotline{overflow: hidden;width: 755px;height: 5px;border-bottom: dotted 1px #b3b5b5;margin-left: auto;margin-right: auto;}");
            sb.AppendLine(".content-footer{border-top: 1px solid #F3F3F3;line-height: 1.8em;padding: 18px 0;color: #999;clear: both;margin-top: 20px;font-size:13px;}");
            sb.AppendLine(".content-footer-left{float: left;}");
            sb.AppendLine(".content-footer-left span{color: #999;padding: 0 5px;}");
            sb.AppendLine(".content-footer-left a{color: #666;text-decoration: none;}");
            sb.AppendLine(".content-footer-right{float: right;text-align: right;}");
            sb.AppendLine("</style>");
            sb.AppendLine("<div class=\"content\"><div class=\"content-line\"><div class=\"content-line-left\"><div class=\"content-logo\">");
            sb.AppendLine("<img src=\"http://" + SiteSettings.Domain + SiteSettings.Logo + "\" /></div>");
            sb.AppendLine("</div><div class=\"content-line-right\"><div class=\"content-toprighttext\"></div>");
            sb.AppendLine("</div></div><div class=\"hline\"></div><div class=\"content-line\"><div class=\"box\"><div class=\"boxbg\">");
            sb.AppendLine("<p>尊敬会员：" + userName + "，<br/>您好！</p>");
            sb.AppendLine("<p>您在" + SiteSettings.SiteName + "申请了重置密码。请点击以下链接以继续您的操作：</p>");
            sb.AppendLine("<p><a href=\"" + url + "\">" + url + "</a></p>");
            sb.AppendLine("<p>如果您未申请过重置密码，请尽快<a target=\"_blank\" href=\"http://" + SiteSettings.Domain + "/account/login\">登录" + SiteSettings.SiteName + "</a>，并修改您的密码</p>");
            sb.AppendLine("</div></div></div><div class=\"content-line\"><div class=\"content-footer\"><div class=\"content-footer-left\">");
            sb.AppendLine("<a href=\"http://" + SiteSettings.Domain + "/home/about\" target=\"_blank\">关于我们</a><span>|</span><a href=\"http://" + SiteSettings.Domain + "/home/contact\" target=\"_blank\">联系我们</a><span>|</span>");
            sb.AppendLine("<a href=\"http://" + SiteSettings.Domain + "/home/business\" target=\"_blank\">商务合作</a><span>|</span><br/>");
            sb.AppendLine("地址：" + SiteSettings.CompanyAddress + "&nbsp;&nbsp;电话：" + SiteSettings.CompanyPhone);
            sb.AppendLine("</div></div></div></div>");
            return sb.ToString();
        }

    }
}
